import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common';

@Injectable()
export class UserPipe implements PipeTransform {
  constructor(private readonly schema) {}
  transform(value: any, metadata: ArgumentMetadata) {
    const { error } = this.schema.validate(value);
    console.log(error);

    if (error) {
      // 如果当前值存在，证明传入的值没有验证通过
      return false;
    }
    return value;
  }
}
